package com.demo.spark.rdd

import org.apache.spark.{SparkConf, SparkContext}

object RddFlatMapScala {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("rdd flat map scala").setMaster("local")
    val context = new SparkContext(conf)
    context.setLogLevel("error")
    val strings = List("hello world", "hi")
    val rdd = context.parallelize(strings)
    val flatList = rdd.flatMap(x => x.split(" "))
    flatList.foreach(x => print(x + ","))

  }

}
